package pers.kw.router;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.*;
import pers.kw.protocol.R;

/**
 * webflux接口
 */
@Configuration
public class RouterFunctionConfiguration {

    @Bean
    public RouterFunction<ServerResponse> routerFunction() {
        return RouterFunctions.route(
                RequestPredicates.GET("/hello"),
                (request) -> ServerResponse.status(HttpStatus.OK)
                        .body(BodyInserters.fromValue(R.ok("这是gateway服务")))
        ).and(RouterFunctions.route(
                RequestPredicates.GET("/hello2"),
                (request) -> ServerResponse.status(HttpStatus.OK)
                        .body(BodyInserters.fromValue(R.ok("这是gateway服务")))
        ));
    }
}
